package com.itmuch.cloud.study.controller;
import com.itmuch.cloud.study.entity.User;
import com.itmuch.cloud.study.repository.UserRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;
/**
 * @author dep
 */
@RestController
public class UserController {
    @Autowired
    private UserRepository userRepository;
    /**
     * 根据用户的id查询用户的信息
     * @param id 用户的id
     * @return
     * @GetMapping 是Spring4.3提供的新注解。它是一个组合注解,等价于@RequestMapping(method=RequestMethod.GET),用于简化开发。
     * 同理还有@PostMapping、@PutMapping、@DeleteMapping、@PatchMapping等
     */
    @GetMapping("/{id}")
    public User findById(@PathVariable Long id) {
        return this.userRepository.findOne(id);
    }
}
